﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using JULONG.WEB.Library;

namespace DFYE.Web.Areas.manage.Controllers
{
    using Models;
    using DFYE.Web.Models;

    public class HomeController : Controller
    {
        AccountClass AccountClass = new Models.AccountClass();

        //
        // GET: /manage/Home/
        public ActionResult Index()
        {
            if (AccountClass.isLogin)
                return View();
            return RedirectToAction("Login");
        }

        public ActionResult Login()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Login(string username, string password)
        {
            if (AccountClass.login(username, password))
                return RedirectToAction("Index");

            ViewBag.username = username;
            ViewBag.info = "用户名或密码错误！";
            return View();
        }
        public ActionResult LoginOut()
        {
            AccountClass.logout();
                return RedirectToAction("Index");

        }

        public ActionResult menus() {
            DataSession<entityDBContainer, channel> db = new DataSession<entityDBContainer, channel>();
            var ss = db.query(d=>d.parentID==null);
            return View("../Shared/manageMenu", ss);
        }
  
    }
}
